package org.zyl.util.code;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;

/**
 * 编码格式
 * @author yzzhouyalei@foxmail.com
 * @time 2017-04-18 10:47:31
 */
public class CodeUtil {
	/**
	 * 编码
	 * @author yzzhouyalei@foxmail.com
	 * @time 2017-04-18 09:42:50
	 */
	public static String getEncode(String value){
		String result = "";
		try {
			result = URLEncoder.encode(value, "UTF-8");
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		return result;
	}
	/**
	 * 解码
	 * @author yzzhouyalei@foxmail.com
	 * @time 2017-04-18 09:42:47
	 */
	public static String getDecode(String value){
		String result = "";
		try {
			result = URLDecoder.decode(value, "UTF-8");
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		return result;
	}
}